{extend name="main/index" /}
{block name="main"}
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="{:url('admin/index/index')}">首页</a>
        </li>

        <li>文章管理</li>
        <li class="active">添加文章</li>
    </ul><!-- .breadcrumb -->

</div>
<div class="container" style="margin-top: 30px;">
    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <form class="form-horizontal" id="add-form"  role="form" action="{:url('admin/arctiles/add')}" method="post" onsubmit="return reForm();" enctype="multipart/form-data">
                <div class="form-group">

                    <label class="col-sm-3 control-label no-padding-right" for="author"> 作者： </label>
                    <div class="col-sm-9">
                        <input type="text" id="author" placeholder="名称" onblur="reAuthor();" name="author" class="col-xs-10 col-sm-5" />
                        <span class="help-inline col-xs-12 col-sm-7">
                        <span class="middle">*必填</span>
                    </span>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="title"> 标题： </label>
                    <div class="col-sm-9">
                        <input type="text" id="title" placeholder="名称" onblur="reTitle();" name="title" class="col-xs-10 col-sm-5" />
                        <span class="help-inline col-xs-12 col-sm-7">
                        <span class="middle">*必填</span>
                    </span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="desc"> 描述： </label>
                    <div class="col-sm-9">
                        <input type="text" id="desc" placeholder="名称" onblur="reDesc();" name="desc" class="col-xs-10 col-sm-5" />
                        <span class="help-inline col-xs-12 col-sm-7">
                        <span class="middle">*必填</span>
                    </span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right"> 封面： </label>
                    <div class="col-sm-9">
                        <input type="file" name="thumb" id="thumb">
                    </span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right"> 状态： </label>
                    <div class="col-sm-9">
                        <label>启用：<input  type="radio"  checked  name="status" value="1"/></label>
                        <label style="margin-left: 20px;">禁用：<input  type="radio"  name="status" value="0" /></label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right"> 父类栏目： </label>
                    <div class="col-sm-9 col-md-3">
                        <select class="form-control" name="cateid" id="cateid">
                            {volist name="data" id="cate"}
                            <option value="{$cate.id}">{:str_repeat('&nbsp;', $cate['count'] * 8).'|--'.$cate['cname'];}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right"> 内容： </label>
                    <div class="col-sm-9 col-md-8">

                        <!-- 加载编辑器的容器 -->
                        <script id="container" name="content" type="text/plain"></script>

                    </div>
                </div>

                <div class="clearfix">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info btn-doadd" type="submit">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script>
        var ue = UE.getEditor('container');
    </script>
    <script>

        $(function(){
            $('#author').focus();
        });

        function reAuthor(){
            var author = $('#author').val();
            if(!/^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/.test(author)){
                $('.middle').eq(0).html('不能包含特殊符号。1到10字符').css({'color': 'red'});
                return false;
            }else{
                $('.middle').eq(0).html('正确').css({'color': 'green'});
                return true;
            }
        }

        function reTitle(){
            var title = $('#title').val();
            if(!/^([a-zA-Z0-9\u4e00-\u9fa5\· \,\。\.\!]{1,30})$/.test(title)){
                $('.middle').eq(1).html('不能包含特殊符号。1到30字符').css({'color': 'red'});
                return false;
            }else{
                $('.middle').eq(1).html('正确').css({'color': 'green'});
                return true;
            }
        }

        function reDesc(){
            var desc = $('#desc').val();
            if(desc.length > 120){
                $('.middle').eq(2).html('1到120字符').css({'color': 'red'});
                return false;
            }else{
                $('.middle').eq(2).html('正确').css({'color': 'green'});
                return true;
            }
        }


        function  reForm() {
            console.log(reAuthor() && reTitle() && reDesc());
           return reAuthor() && reTitle() && reDesc();
        }

        //getContent
        // $('.btn-doadd').click(function(){
        //     if(reAuthor() && reTitle() && reDesc()){
        //         var info = $('#add-form input').serialize();
        //         console.log(info);

            //     $.ajax({
            //         type : 'post',
            //         data : info,
            //         url : "/tag",
            //         success : function(data){
            //             if(data.status){
            //                 alert('添加成功');
            //                 $('#showtag').click();
            //             }else{
            //                 alert('添加失败');
            //             }
            //         },
            //         error : function(){
            //             alert('请求失败');
            //         }
            //     });
            // }else{
            //     alert('验证不通过');
            // }

    </script>




{/block}